package GraphTheory;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.Arrays;

class Solver1106
{	int n;
	int[] Mark;
	int[][] Map;
	
	public void Input() throws IOException
	{	StreamTokenizer in=new StreamTokenizer(new InputStreamReader(System.in));
		in.nextToken();n=(int)in.nval;
		Map=new int[n+1][n+1];
		Mark=new int[n+1];
		Arrays.fill(Mark,-1);
		for (int i=0;i<=n;i++)
			Arrays.fill(Map[i],0);
		for (int i=1;i<=n;i++)
			do
			{	in.nextToken();
				if ((int)in.nval!=0)
				{	Map[i][(int)in.nval]=1;Map[(int)in.nval][i]=1;
				}
			}
			while ((int)in.nval!=0);
	}
	public void Solve()
	{	int count=0;
		for (int i=1;i<=n;i++)
			if (Mark[i]==-1)
			{	Mark[i]=0;count++;
				for (int j=1;j<=n;j++)
					if (Map[i][j]==1) Mark[j]=1;
			}
		Output(count);
	}
	public void Output(int count)
	{	System.out.println(count);
		for (int i=1;i<=n;i++)
			if (Mark[i]==0) System.out.print(i+" ");
	}
	public void main() throws IOException
	{	Input();Solve();
	}
}
public class P1106
{	public static void main(String[] args) throws IOException
	{	Solver1106 solver=new Solver1106();
		solver.main();
	}
}
